Repository navigation
fix: keep the other media type parameters in MultiPartRepresentation.setBoundary - #1606
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The boundary update introduces a NullPointerException for supported null media-type names and discards original descriptions when adding a boundary.
2 open issues
What changed in this PR
This PR addresses #1600 by preserving other media type parameters when MultiPartRepresentation.setBoundary replaces an existing boundary.
Changes:
- Removes existing boundary parameters case-insensitively while respecting quoted values, then appends the new boundary.
- Adds regression coverage for parameter preservation, header-style parameters, null media types, and the instance setter.
- Documents the fix in the changelog.
| File | Description |
|---|---|
org.restlet/src/test/java/org/restlet/engine/connector/MultiPartRepresentationTestCase.java |
Adds boundary replacement regression tests. |
org.restlet/src/main/java/org/restlet/representation/MultiPartRepresentation.java |
Preserves other parameters during boundary replacement and updates documentation. |
changes.md |
Records the fix for #1600. |
Review effort: Balanced
jlouvel
force-pushed
the
fix/multipart-boundary-parameters
branch
from
November 1, 2026 14:58
dde8c94 to
783fb09
Compare
…setBoundary When the media type already had a boundary, setBoundary rebuilt it from the parent type with the boundary only, so "multipart/mixed; boundary=a; deferSpec=20220824" lost deferSpec. A media type's name holds all its parameters, while getParameters() can miss those inherited from an original type. setBoundary now removes the boundary from the name, ignoring case and quoted ';', keeps the other parameters as written, and appends the new boundary. Fixes #1600. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jerome Louvel <[email protected]>
…etBoundary The media type rebuilt without its boundary parameters got the generic description, so even MediaType.MULTIPART_FORM_DATA lost its own. It now keeps the original description. A media type with a null name, which MediaType accepts for backward compatibility, made setBoundary fail with a NullPointerException; its name is now kept as is. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jlouvel
force-pushed
the
fix/multipart-boundary-parameters
branch
from
November 2, 2026 02:11
b395614 to
1db2640
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Fixes #1600.
Summary
When the media type already had a boundary,
MultiPartRepresentation.setBoundary(MediaType, String)rebuilt it from the parent type with the boundary only. Somultipart/mixed; boundary=a; deferSpec=20220824becamemultipart/mixed; boundary=b. The instance methodsetBoundary(String)delegates to it and had the same effect.setBoundarynow edits the media type's name, which holds all its parameters:boundaryparameter, ignoring case and;inside quoted values;The result is unchanged when there was no boundary yet. When a boundary is replaced, it now comes last, which doesn't change the meaning.
Why the name and not
getParameters()MediaTypehas two quirks that makegetParameters()unreliable here:new MediaType(original, name, value)keeps the original's parameters in the name, butgetParameters()returns only the new parameter.MediaType.valueOf("a/b; x=1; y=\"z\"")parses its parameters lazily withForm. Names after the first keep their leading space, and quoted values keep their quotes.Neither quirk is changed here.
Testing
MultiPartRepresentationTestCase.setBoundaryKeepsTheOtherParameterscovers:;boundary=;BOUNDARYfrom a parameter series, as parsed from a header;It failed before the fix. The multipart,
MediaTypeandFormtests pass locally (66 tests). The full core suite runs on CI.🤖 Generated with Claude Code